package org.jeecg.modules.zonglzp.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.jeecg.modules.zonglzp.entity.DepartmentEntity;
import org.jeecg.modules.zonglzp.mapper.DepartmentMapper;
import org.jeecg.modules.zonglzp.service.DepartmentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DepartmentServiceImpl implements DepartmentService {

    @Autowired
    DepartmentMapper mapper;


    //新增部门
    @Override
    public int addDepartment(DepartmentEntity entity) {
        return mapper.addDepartment(entity);
    }


    //查询该客户下的所有部门
    @Override
    public IPage<DepartmentEntity> getDepartment(Page<DepartmentEntity> page, String customerId) {
        return mapper.getDepartment(page, customerId);
    }

    //删除部门
    @Override
    public int deleteDepartment(int id) {
        return mapper.deleteDepartment(id);
    }

    //编辑部门信息
    @Override
    public int updateDepartment(DepartmentEntity entity) {
        return mapper.updateDepartment(entity);
    }

    //通过部门名称查询部门是否已经存在
    @Override
    public String getdepartnamebyname(String departName, String customerId) {
        return mapper.getdepartnamebyname(departName,customerId);
    }


    //查询全部部门 以list返回
    @Override
    public List<DepartmentEntity> getAllDepartmentList(String customerId) {
        return mapper.getAllDepartmentList(customerId);
    }


    //编辑部门时候的详情
    @Override
    public DepartmentEntity getDepartmentbyId(int id) {
        return mapper.getDepartmentbyId(id);
    }


    @Override
    public int getdepartIdbyname(String departName, String customerId) {
        return mapper.getdepartIdbyname( departName,  customerId);
    }
}
